#include"head.h"
int server_rm(int client_fd,char *cmd_argv,char*cur_path)
{   
    char tmp[200]={0};
    strcpy(tmp,cur_path);
    //for(int i=0;i<200;i++)
    //{
    //    if(tmp[i]!='\0')
    //    {
    //        i++;
    //    }
    //    else
    //    {
    //        tmp[i]='/';
    //        tmp[i+1]='\0';
    //        break;
    //    }
    //}
    //未必在当前目录文件夹下进行删除操作
    //必须先cd，再进行rm操作
    //strcat(tmp,"/");
    //strcat(tmp,cmd_argv);

    char buf[200] = {0};
    int exist_test=server_cd(-1,cmd_argv,tmp);
    if(exist_test==-1)
    {
        strcpy(buf,"the path is wrong\n");
        send(client_fd,buf,sizeof(buf),MSG_NOSIGNAL);
        return 0;
    }
    else if(exist_test==0)
    {
        strcpy(buf, "succeed to delete file");
        remove(tmp);
        send(client_fd,buf,sizeof(buf),MSG_NOSIGNAL);
        return 0;
    }
    //int res = remove(tmp);
    //if(res == 0)
    //{
    //    strcpy(buf, "succeed to delete file");
    //}
    //else
    //{

    //    strcpy(buf, "file does not exist");
    //}
    //res = send(client_fd, buf, sizeof(buf), MSG_NOSIGNAL);
    //ERROR_CHECK(res, -1, "server_rm failed send");
    return 0;
}
